package com.example.control;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;

public class TextlnputLayoutActivity extends BaseActivity {

    private TextInputLayout tlUser;
    private EditText etUser;
    private TextInputLayout tlPass;
    private EditText etPass;
    private TextInputEditText eetAccount;
    private TextInputEditText etPwd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_textlnput_layout);
        initView();
    }

    private void initView() {
        tlUser = (TextInputLayout) findViewById(R.id.tl_user);
        etUser = (EditText) findViewById(R.id.et_user);
        tlPass = (TextInputLayout) findViewById(R.id.tl_pass);
        etPass = (EditText) findViewById(R.id.et_pass);
        eetAccount = (TextInputEditText) findViewById(R.id.eet_account);
        etPwd = (TextInputEditText) findViewById(R.id.et_pwd);
    }

    public void login(View view) {

        if(tlUser.getEditText().getText().length() < 6){
            tlUser.setErrorEnabled(true);
            tlUser.setError("账号长度大于6");
        }else {
            tlUser.setErrorEnabled(false);
        }
    }
}